import request from '@/utils/request';

// 职级类型列表
export function fetchGradeTypes(params) {
    // return request('/api/oa/v1/grade/gradetypelist', {
    return request('/api/oa/v2/rank/type/list', {
        method: 'post',
        data: params
    });
}

// 职级类型信息
export function fetchGradeType(typeCode) {
    // return request(`/api/oa/v1/grade/gradetype/${id}`, {
    return request(`/api/oa/v2/rank/type/${typeCode}`, {
        method: 'post'
    });
}

// 职级类型信息历史记录
export function fetchGradeTypeHistory(rankTypeCode) {
    // return request('/api/oa/v1/grade/gradetypehistory', {
    return request('/api/oa/v2/rank/type/history', {
        method: 'post',
        data: { rankTypeCode }
    });
}

// 职级列表
export function fetchGrades(params) {
    // return request('/api/oa/v1/grade/gradelist', {
    return request('/api/oa/v2/rank/list', {
        method: 'post',
        data: params
    });
}

// 职级信息
export function fetchGrade(rankTypeCode) {
    // return request(`/api/oa/v1/grade/grade/${id}`, {
    return request(`/api/oa/v2/rank/${rankTypeCode}`, {
        method: 'post'
    });
}

// 职级历史记录
export function fetchGradeHistory(rankCode) {
    // return request('/api/oa/v1/grade/gradehistory', {
    return request('/api/oa/v2/rank/history', {
        method: 'post',
        data: { rankCode }
    });
}

// 职级类型与职级列表
export function fetchGradeAndType(params) {
    // return request('/api/oa/v1/grade/getPostgradeAndGradetypeList', {
    return request('/api/oa/v2/rank/rankAndRankTypes', {
        method: 'post',
        data: params
    });
}

// 查询当前登陆人所分配的流程模板列表
export function fetchGradeTemplatesByCategory(category) {
    return request('/api/oa/v1/workflow/myprocess/getmyapplytemplatelistbycategory', {
        method: 'post',
        params: { category }
    });
}

// 查询职级的评定维度
export function getRankDimensions() {
    return request('/api/org/v1/rank/dimension//type/list', {
        method: 'get'
    });
}

export function deleteRankCheck(params) {
    return request('/api/org/v1/rank/delete/check', {
        method: 'GET',
        params
    });
}

export function deleteRankTypeCheck(params) {
    return request('/api/org/v1/rank/type/delete/check', {
        method: 'GET',
        params
    });
}

// 职级添加到历史表
export function updateJobRankToHistory(params) {
    return request('/api/oa/workflow/rank/v1/saveRankHiData', {
        method: 'POST',
        data: params
    });
}

export function updateJobRankTypeToHistory(params) {
    return request('/api/oa/workflow/rankType/v1/saveRankTypeHiData', {
        method: 'POST',
        data: params
    });
}

export function fetchProcessFromNewFlow(params) {
    return request('/api/workflowweb/approve/v1/current/navigate/list', {
        method: 'POST',
        data: params
    });
}

export function fetchDetailFromNewFlow(params) {
    return request('/api/workflowweb/approve/v1/cc/detail', {
        method: 'POST',
        data: params
    });
}

export function getPostApplyData(id) {
    return request(`/api/oa/workflow/business/v1/${id}/getBusinessData`);
}
